All Questions
Tagged with interview-questionsperformance
74 questions
2votes
2answers
129views
A thread-safe performant Money Transfer API in Java
This is a popular interview question. It is meant to be done within 30 minutes. The task is to implement a thread-safe performant Bank Account API that allows to transfer, deposit, withdraw and check ...
3votes
3answers
244views
Extracting records from a 2D List of strings
Recently I had an interview question about extracting records that matched certain criteria from a 2D List of strings. The premise was a CSV file was parsed into a ...
2votes
1answer
253views
Detecting timeouts in a stream of events
I'm trying to come up with a solution to this interview question: You have a stream of RPC requests coming into a server which is being logged. Each log entry is of the form [id, timestamp, type ('...
3votes
2answers
194views
Goats up hills II: revenge of the goat
This is a continuation of Goat racing up a hill (C++ hiring take-home) . This is an interview take-home challenge that has been translated to avoid compromising the company's question. Problem ...
6votes
4answers
971views
Counting the number of patterns that exist in a particular string
I am solving this problem where the function returns the number of times a pattern is found in a said string word. It could be easily solved via ...
2votes
1answer
1kviews
Parse a log file into separate column files
This is a follow-up to https://stackoverflow.com/questions/71194832/converting-json-based-log-into-column-format-i-e-one-file-per-column . My task is to optimize this code whose function is to convert ...
2votes
2answers
112views
Print Binary coded decimal Numbering of a given input number
Example 1 input:3 output:0011 Example 2 input : 15 output: 1111 in the below example code 15 is input. I have taken 8 4 2 1 as array for Binary coded decimal numbering this code is working as ...
3votes
3answers
1kviews
Printing rotations of an array 7 times
Loop through a given array 7 times and print the following output: int[] arr = { 9, 2, 7, 4, 6, 1, 3 }; ...
2votes
0answers
105views
Create array given number of larger elements to right of each member
I want to improve on my original solution to this problem, my solution is O(n^2) and I think it's possible to solve in less time You have two arrays: A and B. A contains ints and B has pairs: (...
1vote
2answers
852views
Merge two sorted arrays that can be of different sizes
I think the algorithm implementation itself is reasonably efficient, but I'm not sure about proper use of good practices in software development in the code (variable naming, idioms, comments, error ...
2votes
1answer
114views
Propagation in grid
Can I do it with a lower Big O / better code? How can I improve this solution? Task: Let's assume we have a array like this: 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 ...
3votes
1answer
95views
Traversing from left or from right - Leetcode 140: Word Break II
I have watched Professor Sheep's Leetcode 140: Word Break II YouTube video here CPP code here My own Python translation code is below. I am thinking that the code can be optimized by traversing ...
4votes
2answers
2kviews
Trip planning algorithm
I was presented with an interview question described as follows: Receiving an int[] A of cities, where each A[i] has an appeal ...
12votes
2answers
6kviews
Count the occurrence of each unique word in the file
I've been doing a task for an interview that I will have soon. The requirement is to code the following problem in C#. Write a program (and prove that it works) that: Given a text file, count the ...
2votes
1answer
53views
Find the highest result between two elements in an array using their values and indices
I got a programming question on an interview where performance was the focus. I couldnt come up with a better solution than the one below which I think has a time complexity of O(n^2 + n) and scored ...